package com.kyxx.topics.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.kyxx.topics.BaseActivity;
import com.kyxx.topics.R;
import com.kyxx.topics.adapter.MessageTabFragmentAdapter;
import com.kyxx.topics.adapter.TabFragmentAdapter;
import com.kyxx.topics.fragment.MessageCommentFragment;
import com.kyxx.topics.fragment.MessageNotifyFragment;

import java.util.ArrayList;
import java.util.List;

public class MessageActivity extends BaseActivity {
    private ImageView top_bar_iv_left;
    private TabLayout tl;
    private ViewPager vp;
    private String[] titles = new String[]{"评论", "系统通知"};

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.activity_message);
    }

    @Override
    protected void findViewById() {
        top_bar_iv_left = (ImageView) findViewById(R.id.top_bar_iv_left);
        tl = (TabLayout) findViewById(R.id.tl);
        vp = (ViewPager) findViewById(R.id.vp);

    }

    @Override
    protected void setListener() {
        top_bar_iv_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    protected void processLogic() {
        List<Fragment> fragments = new ArrayList<Fragment>();
        fragments.add(new MessageCommentFragment());
        fragments.add(new MessageNotifyFragment());
        vp.setAdapter(new MessageTabFragmentAdapter(fragments, titles, getSupportFragmentManager(), this));
        tl.setupWithViewPager(vp);
    }
}
